package part2;
/**
 * <p>Title: Project 10 part 2</p>
 * <p>Description: CS 235 Project #10 pt. 2
 *       Shows how to get started with Preconditions, postconditions, and asserts.</p>
 * 
 * AgeData class - this class is a  server class to Part2 and is used to illustrate how
 * the compareTo method has preconditions and postconditions.
 * 
 * @author Anthony Varghese
 * @date   February 5th 2012
 * @version 1.0
 */

import java.lang.Comparable;


public class AgeData implements Comparable{
	/**
	 * Data members
	 */
	private int   idata;
	private float rdata;
	
	/**
	 * AgeData constructor
	 * @param i
	 * @param r
	 */
	public AgeData( int i, float r){
			idata = i;
			rdata = r;
	}
	
	/**
	 * AgeData "copy" constructor
	 * 
	 * @param s
	 */
	public AgeData( AgeData s){
			idata = s.idata;
			rdata = s.rdata;
	}
	
	/**
	 * toString - returns a String equivalent of the data in an AgeData object
	 * 
	 */
	public String toString(){
		return "[ " + idata + ", " + rdata + "]";
	}
	
	/**
	 * compareTo - compares the rdata in this to the rdata in arg0
	 * 
	 * @param - arg0 should be an instance of AgeData
	 * @return an int that satifies the rules of Comparable.compareTo
	 * 
	 * @require
	 * @ensure  
	 */
	public int compareTo(Object arg0) {
		float otherData = ((AgeData)arg0).rdata;
		if (rdata > otherData)
			return 1;
		if (rdata < otherData)
			return -1;
		return 0;
	}

	/**
	 * getIdata - a getter method for the idata int data member
	 * 
	 * @return the current value of idata
	 * 
	 * @require No preconditions
	 * @ensure  this.getIdata() == this.idata
	 */
	public int getIdata() {
		return idata;
	}
}